package com.probox.common.entity.service.customer.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;
import java.util.List;

import com.probox.common.core.utils.StringUtils;
import com.probox.common.entity.service.customer.ICustomerGroupInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.probox.common.entity.mapper.customer.CustomerGroupInfoMapper;
import com.probox.common.entity.domain.customer.CustomerGroupInfo;
import org.springframework.transaction.annotation.Transactional;

/**
 * 客户信息分群关系映射Service业务层处理
 *
 * @author zsy
 * @date 2021-07-15
 */
@Service
@Transactional
public class CustomerGroupInfoServiceImpl extends ServiceImpl<CustomerGroupInfoMapper, CustomerGroupInfo> implements ICustomerGroupInfoService
{
    @Autowired
    private CustomerGroupInfoMapper customerGroupInfoMapper;


    /**
     * 查询客户信息分群关系映射
     *
     * @param customerUid 客户信息分群关系映射ID
     * @return 客户信息分群关系映射
     */
    @Override
    public CustomerGroupInfo selectCustomerGroupInfoById(Long customerUid)
    {
        return this.getById(customerUid);
    }

    /**
     * 查询客户信息分群关系映射列表
     *
     * @param customerGroupInfo 客户信息分群关系映射
     * @return 客户信息分群关系映射
     */
    @Override
    public List<CustomerGroupInfo> queryList(CustomerGroupInfo customerGroupInfo)
    {
        QueryWrapper<CustomerGroupInfo> queryWrapper = Wrappers.query();
                                        if (StringUtils.isNotEmpty(String.valueOf(customerGroupInfo.getCustomerUid()))&&customerGroupInfo.getCustomerUid()!=null)
        {
            queryWrapper.eq("CUSTOMER_UID", customerGroupInfo.getCustomerUid());
        }
                                                if (StringUtils.isNotEmpty(String.valueOf(customerGroupInfo.getGroupId()))&&customerGroupInfo.getGroupId()!=null)
        {
            queryWrapper.eq("GROUP_ID", customerGroupInfo.getGroupId());
        }
                                                if (StringUtils.isNotEmpty(String.valueOf(customerGroupInfo.getStatus()))&&customerGroupInfo.getStatus()!=null)
        {
            queryWrapper.eq("STATUS", customerGroupInfo.getStatus());
        }
                        return customerGroupInfoMapper.selectList(queryWrapper);
    }

    /**
     * 新增客户信息分群关系映射
     *
     * @param customerGroupInfo 客户信息分群关系映射
     * @return 结果
     */
            @Override
    public boolean insertCustomerGroupInfo(CustomerGroupInfo customerGroupInfo)
    {

        return this.save(customerGroupInfo);

    }

    /**
     * 修改客户信息分群关系映射
     *
     * @param customerGroupInfo 客户信息分群关系映射
     * @return 结果
     */
            @Override
    public boolean updateCustomerGroupInfo(CustomerGroupInfo customerGroupInfo)
    {

        return this.updateById(customerGroupInfo);
    }

    /**
     * 批量删除客户信息分群关系映射
     *
     * @param customerUids 需要删除的客户信息分群关系映射ID
     * @return 结果
     */
            @Override
    public boolean deleteCustomerGroupInfoByIds(Long[] customerUids)
    {
        return this.removeByIds(Arrays.asList(customerUids));
    }




}
